//
// Created by Administrator on 2020/1/14.
//

#ifndef WORLDMAGISK_MODULE_MANAGER_H
#define WORLDMAGISK_MODULE_MANAGER_H

#include <string>
#include <jni.h>
#include <map>

typedef jint (*func_on_create_vm)(JavaVM** p_vm,JNIEnv** p_env,void* reversed);

typedef std::string (*func_get_module_name)();

class Module{
public:
    Module(const std::string &path);

    std::string mName;

    bool mReady;

    func_on_create_vm mOnCreateVM;

    ~Module();
private:
    void* mHandle;

    bool GetName();
};
class ModuleManager{
public:
    static ModuleManager* GetInstance(){
        static ModuleManager* instance= nullptr;
        if(!instance)
            instance=new ModuleManager();
        return instance;
    }
    void Add(Module* module);

    std::map<std::string,Module*> mModuleMap;

    Module* Get(const std::string &name);

};
#endif //WORLDMAGISK_MODULE_MANAGER_H
